package main

import (
	"flag"
	"fmt"
	"sync"

	"husd.com/framework/v0/tcp"
)

var c = 0
var lock sync.Mutex

func main() {

	port := flag.Int("port", 20000, "请输入要监听的端口，例如 -port 20000")
	tcp.StartTcpServerWithThread(handle, "127.0.0.1", *port)
}

func handle(bytes []byte) {

	lock.Lock()
	//这里只是简单的转string，然后打印数据即可。
	fmt.Println("tcp server receiver count:", c, "  msg............... ", string(bytes))
	c++
	lock.Unlock()
}
